<?php

use think\migration\Migrator;
use think\migration\db\Column;

class Customer extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $table = $this->table('customer', array('engine' => 'MyISAM', 'comment' => '客户表'));
        $table->addColumn('title', 'string', array('limit' => 55, 'null' => true, 'comment' => '客户名称'))
            ->addColumn('city_id', 'integer', array('limit' => 25, 'null' => true, 'comment' => '所在城市'))
            ->addColumn('trade_id', 'integer', array('limit' => 11, 'null' => true, 'comment' => '行业id'))
            ->addColumn('customer_name', 'string', array('limit' => 30, 'null' => true, 'comment' => '工作单位名称'))
            ->addColumn('customer_phone', 'json', array('limit' => 530, 'null' => true, 'comment' => '手机号'))
            ->addColumn('customer_call', 'string', array('limit' => 55, 'null' => true, 'comment' => '客户称呼'))
            ->addColumn('contact_line', 'string', array('limit' => 55, 'null' => true, 'comment' => '联系人座机'))
            ->addColumn('email', 'string', array('limit' => 55, 'null' => true, 'comment' => '邮箱'))
            ->addColumn('qq', 'string', array('limit' => 55, 'null' => true, 'comment' => 'qq号'))
            ->addColumn('wechat', 'string', array('limit' => 55, 'null' => true, 'comment' => '微信号'))
            ->addColumn('sex', 'boolean', array('limit' => 1, 'default' => 0, 'comment' => '性别'))
            ->addColumn('calendar_id', 'integer', array('limit' => 11, 'default' => 0, 'comment' => '公历、农历'))
            ->addColumn('birthday', 'string', array('limit' => 100, 'default' => 0, 'comment' => '生日日期'))
            ->addColumn('plane', 'string', array('limit' => 225, 'null' => true, 'comment' => '公司座机'))
            ->addColumn('get_customer_time', 'datetime', array('null' => true, 'comment' => '获得客户时间'))
            ->addColumn('customer_status_id', 'integer', array('limit' => 30, 'null' => true, 'comment' => '客户状态'))
            ->addColumn('industry_id', 'integer', array('limit' => 30, 'null' => true, 'comment' => '客户行业'))
            ->addColumn('intention_id', 'integer', array('limit' => 30, 'null' => true, 'comment' => '客户意向产品'))
            ->addColumn('person_in_charge_id', 'integer', array('limit' => 30, 'null' => true, 'comment' => '负责人'))
            ->addColumn('entry_person_id', 'integer', array('limit' => 30, 'null' => true, 'comment' => '录入员'))
            ->addColumn('customer_type_id', 'integer', array('limit' => 30, 'null' => true, 'comment' => '客户类别'))
            ->addColumn('customer_level_id', 'integer', array('limit' => 30, 'null' => true, 'comment' => '客户等级'))
            ->addColumn('customer_source_id', 'integer', array('limit' => 30, 'null' => true, 'comment' => '客户来源'))
            ->addColumn('maturity_id', 'integer', array('limit' => 30, 'null' => true, 'comment' => '成熟度'))
            ->addColumn('address', 'string', array('limit' => 225, 'null' => true, 'comment' => '客户地址'))
            ->addColumn('duties', 'string', array('limit' => 225, 'null' => true, 'comment' => '职务'))
            ->addColumn('remarks', 'text', array('limit' => 0, 'null' => true, 'comment' => '备注'))
            ->addColumn('follow_time', 'datetime', array( 'null' => true, 'comment' => ' 最后跟进时间'))
            ->addColumn('mold', 'boolean', array('limit' => 1, 'default' => 0, 'comment' => '0企业客户，1个人客户，2公共客户'))
            ->addColumn('status', 'boolean', array('limit' => 1, 'default' => 0, 'comment' => '状态0正常跟踪,1交易'))
            ->addTimestamps()
            ->addSoftDelete()
            ->create();
    }
}
